<?php

namespace Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;

class ScheduleTasksSeeder extends Seeder
{
    /**
     * 运行数据库填充
     */
    public function run(): void
    {
        $tasks = [
            [
                'user_id' => 'user_' . Str::random(8),
                'name' => '每日数据备份',
                'delay_time' => '10',
                'jitter_time' => '5',
                'cron_expression' => '0 0 * * *',  // 每天0点执行
                'is_active' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'user_id' => 'user_' . Str::random(8),
                'name' => '系统状态监控',
                'delay_time' => '5',
                'jitter_time' => '2',
                'cron_expression' => '*/15 * * * *',  // 每15分钟执行一次
                'is_active' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'user_id' => 'user_' . Str::random(8),
                'name' => '周报生成任务',
                'delay_time' => '15',
                'jitter_time' => '5',
                'cron_expression' => '0 9 * * 1',  // 每周一9点执行
                'is_active' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'user_id' => 'user_' . Str::random(8),
                'name' => '缓存清理',
                'delay_time' => null,
                'jitter_time' => null,
                'cron_expression' => '0 */4 * * *',  // 每4小时执行一次
                'is_active' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
            [
                'user_id' => 'user_' . Str::random(8),
                'name' => '月度报表统计',
                'delay_time' => '30',
                'jitter_time' => '10',
                'cron_expression' => '0 0 1 * *',  // 每月1号0点执行
                'is_active' => false,
                'created_at' => now(),
                'updated_at' => now(),
            ],
        ];
        
        // foreach ($tasks as $task) {
        //     DB::table('schedule_tasks')->insert($task);
        // }
    }
} 